The operating system (OS) is the software program responsible for supervising all the pieces of your computer.
CPU, RAM, disk, keyboard, display, USB port, WiFi, speakers, etc.
For some of you this is Windows. For others this is Mac OS. You may have also heard of Linux—it's another operating system.
Your CPU (central processing unit) mashes 1's and 0's together to make new 1's and 0's.
We call a single 1 or 0 a bit.
We call 8 1's and 0's a byte.
1 thousand bytes is a kilobyte. 1 million bytes is a megabyte. 1 billion bytes is a gigabyte.
Your disk stores 1's and 0's so you can have them later.
1's and 0's on your disk are still there after you restart your computer.
Your RAM (random access memory) makes 1's and 0's available to your CPU.
1's and 0's in RAM go away when you restart your computer. Your OS will read the 1's and 0's it needs from the disk and put them in RAM.
The 1's and 0's on your disk are organized as files and folders.
A program used to browse your files and folders is called a file browser.
A file is just a bunch of bytes: 1's and 0's.
The file extension communicates to the OS how the bytes should be interpreted.
Do the bytes contain the information of an image? .png, .gif, .jpg
Do the bytes contain the information of a document? .docx, .pages
Do the bytes contain the information of a document that is in a portable document format? .pdf
We use folders to organize our files.
The folder "CS110" could be used to store files and folders for CS110.
Inside the CS110 folder you might have other folders like "Lab1" and "Project2", which contains files that are specific to just those labs and projects.
Every file and folder on your disk belongs to another folder.
Except for one: root
C:
/
The term path is the address of a file or folder.
Paths that start with the root are called rooted or absolute paths.
C:\Users\gbean\Downloads\cello-song.mp3
/Users/gbean/Downloads/cello-song.mp3
Paths that start with the current directory are called relative paths.
If I am currently in /Users/gbean
, then Downloads/cello-song.mp3
describes the file /Users/gbean/Downloads/cello-song.mp3
If I am currently in /Users/gbean
, then syllabus.pdf
describes the file /Users/gbean/syllabus.pdf
I can also refer to the current directory using .
.
So, if I am currently in /Users/gbean
, then ./syllabus.pdf
describes the file /Users/gbean/syllabus.pdf
.
Windows example:
If I am currenlty in C:\Users\gbean
, then .\syllabus.pdf
describes the file C:\Users\gbean\syllabus.pdf
I can refer to the parent directly using ..
If I am currently in /Users/gbean/Documents
, the path ../Downloads/cello-song.mp3
refers to /Users/gbean/Downloads/cello-song.mp3
Windows: C:\Users\gbean\Documents
, ..\Downloads\cello-song.mp3
, C:\Users\gbean\Downloads\cello-song.mp3
Given the current folder of /Users/gbean/Documents/CS110
, what is the absolute path of the following files or folders:
./syllabus.pdf
lesson-schedule.txt
/Users/gbean/Documents/CS235/syllabus.pdf
../CS235/Lab1/spec.md
Lab1/instructions.html
../CS110/Lab2/instructions.html
../../Downloads/assignment1.zip
./Project1/../Lab3/stuff/input.txt
A terminal is a program that gives us the ability to browse files and folders and run programs using only text.
pwd
¶pwd
stands for print working directory.
It tells us the path to the current, or working, directory.
ls
¶ls
stands for list. It lists the files and folders in the working directory.
You can also specify the path you want to list.
cd
¶cd
stands for change directory.
You specify the path you want to change to, and that new path becomes the working directory.
start <file or folder>
open <file or folder>
Typing out paths and file names can be tedious.
Humans are also notorious for making typos.
Your terminal is eager to help you.
Start typing something. Press the tab key. What happens?
Press tab once to auto-complete whatever you are typing.
Sometimes, what you are typing is ambiguous (e.g. you typed cell
but there are files named cello-song.mp3
and cell-phone-plan.pdf
).
In these cases, depending on your terminal, you have some options:
The process of designing instructions for a computer is called programming.
Everything a computer does is just 1's and 0's.
But humans don't communicate well in 1's and 0's.
So instead of programming in 1's and 0's, we use programming languages. We call instructions written in a programming language code.
Special programs translate code into 1's and 0's.
Python is:
We write code using a code editor.
Just like you write documents using a document editor (e.g Microsoft Word), there are programs to make writing code easer.
In this class we will use PyCharm. It is a code editor designed especially for Python.